package com.mc.moring.main.adapter

import android.content.Context
import android.view.View
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.mc.moring.R
import com.mc.moring.bean.baseBean.LoanData
import java.util.*

/**
 * msg
 * author: Created by nao on 2018-09-18
 * version: 1.0.0
 */
class MyLoanListAdapter(val context: Context, val data: ArrayList<LoanData>, layoutId: Int) :
    NArrayListAdapter<LoanData>(context, data, layoutId) {

    override fun getViewHolder(): BaseViewHolder = ViewHolder()

    override fun initView(viewHolder: BaseViewHolder, convertView: View, position: Int) {
        val mViewHolder = viewHolder as ViewHolder
        mViewHolder.status = convertView.findViewById(R.id.tv_status)
//		mViewHolder.time = convertView.findViewById(R.id.tv_time)

//		mViewHolder.imageView = convertView.findViewById(R.id.imageView)
    }

    override fun setData(viewHolder: BaseViewHolder, convertView: View, position: Int) {
        if (mData == null || mData.isEmpty()) {
            return
        }
        val listBean = mData[position]
        val mViewHolder = viewHolder as ViewHolder

        mViewHolder.status.text = listBean.title

        mViewHolder.status.setBackgroundResource(
            when (listBean.type) {
                0 -> R.drawable.btn_circle_line_red_bg
                1 -> R.drawable.btn_circle_line_green_bg
                2 -> R.drawable.btn_circle_line_yellow_bg
                3 -> R.drawable.btn_circle_line_grey_bg
                else -> R.drawable.btn_circle_line_grey_bg
            }
        )

        val color = when (listBean.type) {
            0 -> R.color.text_red_color
            1 -> R.color.text_green_color
            2 -> R.color.text_yellow_color
            3 -> R.color.text_grey_color
            else -> R.color.text_grey_color
        }
        mViewHolder.status.setTextColor(ContextCompat.getColor(mContext, color))

//		mViewHolder.time.text = listBean.createTime

//		val picPath = CommonUtil.loadUrl(listBean.picPath)
//		GlideUtils(mContext).loadRoundedView(picPath, 15, mViewHolder.imageView)
    }

    internal class ViewHolder : BaseViewHolder() {
        lateinit var status: TextView
    }
}
